package com.bluesky.plum.domain.repository.search.condition;

import com.bluesky.plum.domain.repository.search.operator.LogicOperator;

public class ExpressCondition extends Condition {
	Condition o1;
	Condition o2;

	LogicOperator operator;

	public ExpressCondition(Condition c1, Condition c2, LogicOperator operator) {

		this.o1 = c1;
		this.o2 = c2;
		this.operator = operator;
	}

	@Override
	public Object getValue() {

		return operator.operate(o1.getValue(), o2.getValue());
	}

	@Override
	public String toString() {

		return String.format("(%s %s %s)", o1, operator, o2);
	}
}
